﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcSite.Models;

namespace MvcSite.Controllers
{
    public class AlbumController : Controller
    {

        public ActionResult Index()
        {
            ViewData["ListAlbum"] = GestoreAlbum.ListAlbum(true);
            return View();
        }

        public ActionResult AdminIndex()
        {
            return View();
        }

        public ActionResult ListAlbum()
        {
            ViewData["ListAlbum"] = GestoreAlbum.ListAlbum();
            return View();
        }

        public ActionResult ModifyAlbum(int id)
        {
            ViewData["Album"] = GestoreAlbum.GetAlbum(id);
            return View();
        }

        public bool AlbumExist(string nome)
        {
            return GestoreAlbum.AlbumExist(nome);
        }

        public void CreateAlbum(string Nome)
        {
            try
            {
                GestoreAlbum.CreateAlbum(Nome);
            }
            catch
            {
            }
        }

        public bool RenameAlbum(int id, string newName)
        {
            try
            {
                GestoreAlbum.RenameAlbum(id, newName);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public bool DeleteAlbum(int id)
        {
            GestoreAlbum.DeleteAlbum(id);
            return true;
        }

        public ActionResult FotoAlbum(int album)
        {
            ViewData["ListFoto"] = GestoreFoto.LoadFoto(album);
            return View("Gallery");
        }
        
    }
}
